<template>
  <div>
    <el-form ref="form" :model="form" :rules="rules" style="margin-top: 6px;" size="small" label-width="90px">
      <el-form-item label="商品Id" prop="syId">
        <el-input v-model="form.syId" style="width: 35%" />
      </el-form-item>
      <el-form-item label="规格类型" prop="ruleType">
        <el-input v-model="form.ruleType" style="width: 35%" />
        <span style="color: #C0C0C0;margin-left: 10px;">规则类型：0手机 1平板;默认是0</span>
      </el-form-item>
      <el-form-item label="规格JSON串" prop="body">
        <el-input v-model="form.body" rows="10" type="textarea" />
      </el-form-item>
      <el-form-item label="">
        <el-button :loading="loading" size="medium" type="primary" @click="doSubmit">录入</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { inertJsonData} from '@/api/tools/alipay'
import { Message } from 'element-ui'
export default {
  data() {
    return {
      url: '',
      // 新窗口的引用
      newWin: null,
      loading: false, form: { syId: '', ruleType: '', body: '' },
      rules: {
        syId: [
          { required: true, message: '商品ID不能为空', trigger: 'blur' }
        ],
        ruleType: [
          { required: true, message: '规格类型不能为空', trigger: 'blur' }
        ],
        body: [
          { required: true, message: '规格JSON串不能为空', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    doSubmit() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          this.loading = true
          
          inertJsonData(this.form).then(res => {
            this.loading = false
            Message({ message: '设置成功', type: 'success' })
          }).catch(err => {
            this.loading = false
            console.log(err.response.data.message)
          })
        } else {
          return false
        }
      })
    }
  }
}
</script>

<style scoped>
</style>
